package com.oazon.sonos.core;

import android.content.Context;

import com.moco.launcher.bean.MOCO_CONSTANTS;
import com.oazon.common.Logger;
import com.oazon.moco.bean.McServiceMsg;
import com.oazon.sonos.bean.GetMetadata;
import com.oazon.sonos.bean.Search;
import com.oazon.sonos.listener.SonosListener;
import com.oazon.sonos.util.SessionIdHelper;
import com.oazon.sonos.util.DeviceLinkHelper;

public class ThreadControler implements ISonosSoap {

	private AbsServiceHelper helper;
	private final String TAG = "ISonosSoap";
	
	public ThreadControler(Context context,McServiceMsg serViceMsg){
		if("device_link".equals(serViceMsg.getAuthType())){
			helper = new DeviceLinkHelper(context,serViceMsg);
		}else if("session_id".equals(serViceMsg.getAuthType())){
			helper = new SessionIdHelper(context,serViceMsg);
		}
	}

	@Override
	public void getMetadata(Context context, GetMetadata parameters,
			SonosListener listener) {
		helper.getMetadata(parameters.getId(),
				parameters.getIndex(), parameters.getCount(), listener);
	}

	@Override
	public void getMediaURI(Context context, String id, String provider,
			SonosListener listener) {
		helper.getMediaURI(id, listener);
	}

	@Override
	public void search(Context context, Search parm, SonosListener listener) {
		Logger.d(TAG, parm.getProvider()+"->search:" + parm);
		helper.search(parm.getId(), parm.getIndex(),
				parm.getCount(), parm.getTerm(), listener);

	}

	@Override
	public void registMcServiceMsg(McServiceMsg msg) {
		helper.registMcServiceMsg(msg);
		
	}

	@Override
	public AbsServiceHelper getServiceHelper() {
		return helper;
	}

}
